﻿#ifndef _COBJECT_H_
#define _COBJECT_H_

#include <d3dx9.h>
#include "Sprite.h"
#include "Camera.h"

#include "DxInput.h"
//#include "MarioManager.h"

class QuadTree;
//class MarioManager;

enum OBJECT_TYPE
{
	OBJECT_MARIO, 
	OBJECT_LAND, 
	OBJECT_PIPE, 
	OBJECT_SCENE, 
	OBJECT_ENEMY,
	OBJECT_ITEM
};

class Object
{
protected:
	Sprite* _sprite;	//hinh anh doi tuong
	 
	float _x;			//toa do x
	float _y;			//toa do y
	RECT _rectBond;		//khung hinh chu nhat cua doi tuong

	int		ID;				//Mã của từng loại đối tượng. 
public:
	D3DXVECTOR2 	m_collisionResponse;
	//RECT	rect;
	
	QuadTree* oldNode;

	Object* container;

	int object_State;		//trang thai cua object
	int direction;			//huong cua object
	//MarioManager* game;

	Object();
	Object(float x, float y);
	Object(float x, float y, float width, float height);
	~Object();
	 
	virtual void Update(int _ScreenWidth, int _ScreenHeight, float gameTime); // Update vi tri theo thoi gian
	virtual void Render();

	 
	bool IsCollideWith(Object* another);		//Kiem tra va cham
	RECT GetIntersectBond(Object* another);		//Lay RECT va cham
	bool IsPointIn(D3DXVECTOR2 point);			//kiem tra 1 diem co thuoc RECT hay k
	 
	virtual void ResetRect();
	RECT GetBond() { return _rectBond; }
	virtual OBJECT_TYPE GetTypeObject() ;//{return NULL;} ;
	float GetX(){return _x;}
	float GetY(){return _y;}
	void SetX(float x){_x = x;}
	void SetY(float y){_y = y;}
	Sprite *GetSprite(){return _sprite;}
	int GetID(){return ID;}
	void SetID(int id){ID = id;}

	virtual void Update(list<Object*>* staObjs, list<Object*>* dynObjs, DxInput* input, float TPF){};
	virtual void ChangeState(int state){object_State = state;}
	virtual D3DXVECTOR2 GetPosition()
	{
		D3DXVECTOR2 position;
		position.x = _x;
		position.y = _y;
		return position;
	}
};
#endif